main: Update pointer focus state for button releases
authorMatthias Clasen <mclasen@redhat.com>
Sat, 19 Sep 2020 20:45:56 +0000 (16:45 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 19 Sep 2020 20:48:15 +0000 (16:48 -0400)
Failure to do so makes the old pointer focus target
'sticky', because we end up ignoring the result of
picking the pointer focus until a motion event comes
in.

Fixes: #3172
gtk/gtkmain.c

index a72801e8dd9c407477821c193f17a69332efa1ee..10780b7684353dd460d937281a3d68c4b7d39f30 100644 (file)
@@ -1477,17 +1477,19 @@ handle_pointing_event (GdkEvent *event)
                                                                  device,
                                                                  sequence);
       gtk_window_set_pointer_focus_grab (toplevel, device, sequence,
-                                         type == GDK_BUTTON_PRESS ?
-                                         target : NULL);
+                                         type == GDK_BUTTON_PRESS ?  target : NULL);
 
       if (type == GDK_BUTTON_RELEASE)
         {
           GtkWidget *new_target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT);
+
           if (new_target == NULL)
             new_target = GTK_WIDGET (toplevel);
+
           gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, target, new_target,
                                           event, GDK_CROSSING_UNGRAB, NULL);
           gtk_window_maybe_update_cursor (toplevel, NULL, device);
+          update_pointer_focus_state (toplevel, event, new_target);
         }
 
       set_widget_active_state (target, type == GDK_BUTTON_RELEASE);